import 'package:flutter/material.dart';
import 'package:flutter_screenutil/screen_util.dart';
import 'package:flutter_teacher/view/alumni/index.dart';
import 'package:flutter_teacher/widget/s_tab.dart';

class IndexMessagePage extends StatefulWidget {
  @override
  _IndexMessagePageState createState() => _IndexMessagePageState();
}

class _IndexMessagePageState extends State<IndexMessagePage> {
  final List<Widget> tabBodies = [
    Message(),
    IndexAlumniCirclePage(),
  ];

  @override
  Widget build(BuildContext context) {
    return Container(
      padding: EdgeInsets.only(top: 30),
      decoration: BoxDecoration(color: Color(0xffF7F7F7)),
      child: STab(
        tabs: ["消息", "收藏"],
        pages: tabBodies,
      ),
    );
  }
}

class Message extends StatelessWidget {
  List list = [1, 23, 3, 3, 3, 33];

  @override
  Widget build(BuildContext context) {
    return Container(
      child: SingleChildScrollView(
        child: Column(
          children: list.map((e) => messageItem()).toList(),
        ),
      ),
    );
  }

  Widget messageItem() {
    var s = SizedBox(
      width: 10,
    );
    return Container(
      padding: EdgeInsets.only(left: 10, top: 10),
      child: Row(
        crossAxisAlignment: CrossAxisAlignment.end,
        children: [
          studentHead(),
          s,
          ss(),
          s,
          message()
        ],
      ),
    );
  }

  Widget studentHead() {
    return Container(
      height: ScreenUtil().setHeight(30),
      width: ScreenUtil().setHeight(30),
      decoration: BoxDecoration(
          borderRadius: BorderRadius.all(Radius.circular(50)),
          color: Colors.deepPurpleAccent),
    );
  }

  Widget message(){
    return Container(
      child: Column(
        mainAxisAlignment: MainAxisAlignment.spaceBetween,
        children: [
          Text("学校消息"),
          SizedBox(height: ScreenUtil().setHeight(10),),
          Text("1111111")
        ],
      ),
    );
  }
  Widget ss() {
    return Container(
      height: ScreenUtil().setHeight(50),
      width: ScreenUtil().setHeight(50),
      alignment: Alignment.topRight,
      child: Stack(
        children: [
          Container(
            decoration: BoxDecoration(
                color: Colors.amber,
                borderRadius: BorderRadius.all(Radius.circular(50))),
          ),
          Container(
            alignment: Alignment.topRight,
            child: Container(
              alignment: Alignment.center,
              height: ScreenUtil().setHeight(20),
              width: ScreenUtil().setHeight(20),
              decoration: BoxDecoration(
                  color: Colors.white,
                  borderRadius: BorderRadius.all(Radius.circular(50))),
              child: Container(
                height: ScreenUtil().setHeight(15),
                width: ScreenUtil().setHeight(15),
                decoration: BoxDecoration(
                    color: Colors.lightGreen,
                    borderRadius: BorderRadius.all(Radius.circular(50))),
              ),
            ),
          )
        ],
      ),
    );
  }
}
